import 'dart:io';

import 'package:hive/hive.dart';
import 'package:test2/util/PicUtil.dart';
part 'scene.g.dart';

@HiveType(typeId: 3)
class SceneC extends HiveObject{
  @HiveField(0)
  String tip;

  @HiveField(1)
  String positionPic;
  @HiveField(2)
  String scenePic;

  @HiveField(3)
  bool done;
  @HiveField(4)
  String tag;

  SceneC({
    required this.tip,
    required this.positionPic,
    required this.scenePic,
    required this.done,
    required this.tag,
  });

  void deletePicPos() {

    File oldFile = File(PicUtil.picRootPath + positionPic);
    if (oldFile.existsSync()) {
      oldFile.delete();
    }
  }

  void deletePicScene() {
    print("delete " + scenePic);

    File oldFile = File(PicUtil.picRootPath + scenePic);
    if (oldFile.existsSync()) {
      oldFile.delete();
    }
  }

  Future deleteSelf() async {
    await delete();
    deletePicPos();
    deletePicScene();
  }
}
